package com.oscar.ehome.view.pageview.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.oscar.ehome.R;
import com.oscar.ehome.base.C;
import com.oscar.ehome.bean.pagebean.XiaoXiFinalBean;
import com.oscar.ehome.provider.gildeimage.GildeUtils;

import java.util.List;

/**
 * Created by juxing
 * author: MengWanhe
 * date: On 2017/12/7
 */

public class MessageYiduAdapter extends BaseAdapter {
    protected Context mContext;
    protected List<XiaoXiFinalBean.ReadUserList> mDatas;

    protected LayoutInflater mInflater;



    public MessageYiduAdapter(Context context, List<XiaoXiFinalBean.ReadUserList> mDatas) {
        this.mContext = context;
        this.mDatas = mDatas;
        mInflater = LayoutInflater.from(mContext);
    }


    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        MessageYiduAdapter.ViewHolder vh;
        if (convertView == null) {
            vh = new MessageYiduAdapter.ViewHolder();
            convertView = View.inflate(parent.getContext(), R.layout.adapter_teamlist_item_city, null);
            vh.team_item_name = (TextView) convertView.findViewById(R.id.team_item_name);
            vh.team_item_imghead = (ImageView) convertView.findViewById(R.id.team_item_imghead);
            vh.team_item_level = (TextView) convertView.findViewById(R.id.team_item_level);

            vh.tv_word = (TextView) convertView.findViewById(R.id.tv_word);

            convertView.setTag(vh);
        } else {
            vh = (MessageYiduAdapter.ViewHolder) convertView.getTag();

        }

        vh.tv_word.setVisibility(View.GONE);
        vh.team_item_name.setText(mDatas.get(position).getName());
        vh.team_item_level.setText(mDatas.get(position).getRoleMobile().getRoleName());
        String photo = C.qiniu + mDatas.get(position).getPhoto();
//        GildeUtils.imgLoadPic(mContext, photo, vh.team_item_imghead, "net-p");
        GildeUtils.loadUrlImage4(photo, vh.team_item_imghead, mContext);






        return convertView;
    }

    public class ViewHolder {
        TextView team_item_name;
        ImageView team_item_imghead;

        TextView team_item_level;

        TextView tv_word;
    }

}
